﻿using System.Windows.Controls;
using GameLogic.Controls;

#if WINDOWS_PHONE

using Microsoft.Phone.Shell;

#endif

namespace GameLogic.Pages
{
    public partial class GamePage : UserControl
    {
        public GamePage()
        {
            InitializeComponent();

#if WINDOWS_PHONE
            this.Loaded += (s, e) =>
                {
                    GameContainer.ApplicationBar.Opacity = .5;
                    GameContainer.ApplicationBar.IsVisible = true;

                    GameContainer.ApplicationBar.Buttons.Clear();
  
                    // Pause
                    ApplicationBarIconButton pause = new ApplicationBarIconButton();
                    pause.Text = "Pause";
                    pause.IconUri = new Uri("/GameLogic;component/Assets/appbar.add.rest.png", UriKind.Relative);
                    pause.Click += (s1, e1) =>
                        {
                            pause.IsEnabled = false;
                            play.IsEnabled = true;

                            _game.Pause();
                        };
                    GameContainer.ApplicationBar.Buttons.Add(pause);

                    stop = new ApplicationBarIconButton();
                    stop.Text = "Stop";
                    stop.IconUri = new Uri("/GameLogic;component/Assets/appbar.add.rest.png", UriKind.Relative);
                    stop.Click += (s1, e1) =>
                    {
                        _game.Stop();
                        GameContainer.NavigationService.Navigate(Const.MenuPageUri);
                    };
                    GameContainer.ApplicationBar.Buttons.Add(stop);

                    play = new ApplicationBarIconButton();
                    play.Text = "Play";
                    play.IconUri = new Uri("/GameLogic;component/Assets/appbar.add.rest.png", UriKind.Relative);
                    play.Click += (s1, e1) =>
                    {
                        play.IsEnabled = false;
                        pause.IsEnabled = true;
                        _game.Resume();
                    };
                    GameContainer.ApplicationBar.Buttons.Add(play);

                    play.IsEnabled = false;

                };
#endif
        }

        IGameFeatures _game = GameContainer.GameControlStatic as IGameFeatures;

#if WINDOWS_PHONE
        ApplicationBarIconButton pause;
        ApplicationBarIconButton play;
        ApplicationBarIconButton stop;
#endif

    }
}
